Skip to content

fix(factscribe): find Python on Windows, keep CRLF line endings on save - #160

Merged
MyPrototypeWhat merged 4 commits into
MiniMax-AI:mainfrom
UncleMoc:feature/factscribe-windows-and-eol
Nov 27, 2026
Merged

MyPrototypeWhat merged 4 commits into
MiniMax-AI:mainfrom
UncleMoc:feature/factscribe-windows-and-eol

Conversation

@UncleMoc

@UncleMoc UncleMoc commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Three fixes for the FactScribe Paper Workbench package. The vendored Python
engine now reads and fingerprints the manuscript on one line-ending basis, so a
manuscript with CRLF line endings can be saved with the paragraph fingerprint
the page just gave it; on Windows the Mini App can find the Python interpreter
the machine already has; and saving a manuscript no longer rewrites its line
endings. The vendored Python engine has been upgraded as well: it keeps the
file's own line endings itself instead of leaving that to the Node shell to put
back afterwards, and it no longer crashes on a Chinese Windows console or on a
write target whose landing point cannot be resolved.

Written by MiniMax Code (MCode)

The paragraph fingerprint and the manuscript's line endings

This was a blocking review on this PR, and it is reproduced and fixed here.

What was broken

The page and the save path read the same manuscript differently, and the
paragraph fingerprint is a sha256 over that text - so a manuscript with CRLF
line endings could not be saved with the fingerprint the page had just given
it.

  • The page went through the audit closure (factscribe/config.py::_read_text
    -> Path.read_text()), which reads in universal-newline mode: a CRLF file
    was already LF by the time the paragraph reached the browser.
  • The save path reads the file byte-exact
    (factscribe/textio.py::read_text_exact, newline=""), so the raw it
    fingerprints still had its CR bytes in it.

The two sides therefore disagreed by exactly the CR bytes, and the fingerprint
gate refused the save with HTTP 409 BLOCK_STALE ("this paragraph was
changed elsewhere, please edit it again"). A paragraph whose text is a single
line hid the defect - there are no CR bytes inside it, so both sides happened
to agree. That is why the earlier end-to-end test passed: it saved the
section heading, a one-line block.

Reproduced at 908bdf9 and still present at 3adf295 (the two earlier commits
on this branch do not touch the fingerprint path): open a document whose body
has several CRLF lines, take the paragraph fingerprint from the page
response, save with it:

POST /api/disk/guide/guide/edit   file=sections/01-intro.tex  block=01-intro-p1
-> HTTP 409  {"ok":false,"code":"BLOCK_STALE",
              "error":"this paragraph was changed elsewhere, please edit it again"}

The page had answered with sha 501dfe617f20e728 (the fingerprint of the LF
text) while the save path computed 145322cc931203af (the fingerprint of the
same paragraph with its CRLF endings).

What changed

Both sides now use the file's own bytes.

  • factscribe/workbench/projects.py::_section_files reads each section file
    with read_text_exact instead of taking the closure's universal-newline
    text, so the raw the page is rendered from is the raw the save path
    fingerprints. The cover abstract follows the same rule in both of its
    layouts (a section file and the root file), which used to disagree with
    each other as well.
  • The fingerprint itself is unchanged - sha256 over the block raw, first 16
    hex digits (factscribe/workbench/projects.py::short_sha). Only the text it
    is taken over is now the same on both sides.

Saving still preserves the manuscript's own line endings, byte for byte:

  • New factscribe/textio.py::restore_newlines puts the block's original
    endings back on the text that is about to be written. A contenteditable
    always hands back LF (the DOM has no CRLF), so without this a CRLF file
    would lose its CR bytes on the first save. The endings are restored per
    line
    , so a file with mixed endings stays mixed, and endings the block did
    not have are taken from the file.
  • The structural work - protection-surface scan, anchor re-insertion, surface
    comparison - runs on the LF-normalised copy on both sides, so a CRLF
    manuscript takes exactly the same decisions as an LF one. The judgement
    codes, the wording and the exit codes are untouched.

The regression test the review asked for

New tests/save-fingerprint.test.mjs covers the whole flow:

  1. open a document whose body is a multi-line CRLF paragraph;
  2. take the paragraph fingerprint and the prose from the page response
    (GET /api/disk/<project>/<disk>/block/<id>);
  3. save that paragraph with that fingerprint
    (POST /api/disk/<project>/<disk>/edit);
  4. assert that the save succeeds and that the file on disk is byte-identical
    to the file before the save
    - same bytes, same CRLF endings.

Two more cases: the same flow for an LF body (it must not come back as
CRLF), and the same CRLF file with the LF text a browser actually sends (it
must come back as CRLF).

The new test is red against 3adf295 (409 BLOCK_STALE) and green with this
change. tests/save-eol.test.mjs now derives the package root with
fileURLToPath, so the package's own test suite also runs on Windows (a URL
pathname is /C:/... there).

Windows interpreter discovery

The candidate list had no Windows shape at all — no py launcher, no versioned command, no common install directory — and a failed probe was collapsed into "not installed". A user with Python 3.9 on the machine was told to "install Python >=3.10", with nothing they could act on.

  • New miniapp/node/python_discovery.mjs. Candidates are now {command, args} pairs and cover py, py -3, py -3.10 … py -3.14, py.exe, the versioned commands, python.exe, and absolute paths under %LOCALAPPDATA%, %PROGRAMFILES% and C:\Python3xx — 36 candidates on Windows. The macOS/Linux list is unchanged, word for word.
  • The probe classifies the outcome: version high enough / version too low / command missing / command present but the version cannot be read. The message therefore names the version it found and the executable it came from.
  • Discovery and engine start share one "command + prefix arguments" pair, so py -3 starts the engine too, not only the probe.
  • The settings page and the engine start failure now share one message, which distinguishes: nothing installed / installed but older than 3.10 (3.9 and below cannot run this engine) / installed but not on PATH (point FS_PYTHON at it) / a Microsoft Store placeholder alias that cannot report its version.

The requirement itself is unchanged: the engine needs Python >= 3.10.

Browser-layer CRLF preservation

The engine used to read sections with Python's universal-newline mode — CRLF became LF before the text ever reached the page — and wrote the file back byte for byte. Every save therefore rewrote the whole file with LF endings, so a CRLF manuscript lost all its CR bytes on the first edit. The browser layer is the first line of defence and stays.

  • New miniapp/node/eol.mjs: split the text with the endings kept apart, recognise crlf / lf / mixed, and put the original endings back.
  • The Node shell reads the real endings from the file on disk before the save, hands the engine an LF-only body, and restores the endings afterwards. Lines the save did not touch keep their exact endings (a file with mixed endings stays mixed), the edited lines take the file's dominant ending, and the text itself is never altered — only the endings move. If the file changed underneath while the save ran, the endings are left alone instead of overwriting someone else's work.

The vendored Python engine keeps line endings too

The package ships a copy of the Python engine under miniapp/node/engine/, and that copy was still the older build. It read user files in universal-newline mode, so a CRLF file was already LF by the time the text reached the page, and it wrote several user-owned files in platform default text mode, where a CRLF string is written as \r\r\n on Windows. The Node shell puts the endings back after each save, so the file on disk looked right — but the engine had already lost the endings, and the Node layer can only repair a file whose line contents still match.

The vendored engine has been re-vendored from the engine source tree:

  • New factscribe/textio.py: read_text_exact / write_text_exact / append_text_exact read and write with the file's own line endings — no universal-newline translation on the way in, no platform translation on the way out — and to_lf gives the analysis layer one explicit place where line endings are normalised in memory. Machine-generated artefacts (JSON reports, audit matrices, manifests) keep the platform default, so their format stays predictable.
  • The read side of the manuscript, fact ledger, glossary and workbench paths now uses read_text_exact; the write side uses write_text_exact.
  • The vendored tree is generated by the engine repository's miniapp/build.sh and is byte-identical to the source tree apart from the excluded web/ directory.

The vendored Python engine also fixes two Windows defects

Two more Windows defects were found on a real Windows host (winbox 10.0.1.9, console code page ACP=936 / gb2312) after the engine above had been vendored. Both are fixed in the engine source tree, and this vendored copy carries the fixes.

D1 - a write-side landing point that cannot be resolved must be refused, not crash

The engine resolved write targets with pathlib.Path.resolve(). On a symlink cycle that raises RuntimeError on Python 3.10-3.12 and does not raise at all on 3.13+, so a section file that was a symlink loop escaped as an uncaught exception - "internal error", exit 4 - instead of a refusal with a judgement code. A section symlinked outside the project escaped the same way from the closure builder.

  • New factscribe/landing.py owns landing resolution. It resolves with os.path.realpath(strict=True), so every Python version gives the same answer, and it judges "cannot be resolved" semantically instead of by an errno whitelist: on Windows a symlink cycle raises OSError(winerror=1921, errno=22 EINVAL), not ELOOP (the Windows errno.ELOOP constant is 10062), so a whitelist would miss it on that platform.
  • The three write gates - _safe_section_file, _root_tex_file, write_section_data - now refuse with their own existing codes (SECTION_PATH_INVALID / PATH_ESCAPE) instead of crashing. The "outside the project root" wording is unchanged, and an in-project symlink is still written through.

D2 - a Chinese Windows console must not break the tool

The human-readable output contains U+2713 / U+2717 / U+2194, which cp936 cannot encode. print() raised UnicodeEncodeError and the command layer turned that into exit 4.

  • New factscribe/console.py installs a custom encoding error handler on stdout/stderr at the CLI entry: characters that cannot be encoded become equivalent ASCII (checkmark to v, xmark to x, arrow to <->). The command runs to completion and keeps its own exit code, the stream keeps its own encoding (Chinese text redirected to a file is unchanged), and --json payloads are untouched.

What this does not change

This engine line has no write-side landing gate of its own - the gate is a feature of the main engine repository, not of this package - so there is no FACT_FILE_UNRESOLVED code and no exit-5 contract here. What this PR transplants is the principle: a landing point that cannot be resolved is refused with a judgement code, never a bare exit 4. No other code, exit code or wording was touched.

Tested environment and results

  • MiniMax Code 3.1.16 on macOS 26.6.2 (arm64); Node 26.7; Python 3.14.
  • Windows NT 10.0.26200.9974 on a real host (winbox 10.0.1.9), console code page ACP=936 / gb2312, portable Python 3.12.10 (embeddable, nothing installed), Node 24.22.2.
  • Upstream checker: plugins/unclemoc/factscribe: OK — 0 errors, 0 warnings. npm run check exits 0 (92/92 checker self-tests).
  • Package tests: node --test tests/*.test.mjs — 22 cases, all green (16 unit cases for the line-ending module, 3 end-to-end cases that start the vendored Python engine and save into a copy of the sample paper, and 3 new end-to-end cases for the paragraph fingerprint).
  • The engine's own Python test suite (2399 cases and 397 subtests, all green on Python 3.14) passes against the vendored copy inside this package.
  • The blocked save, measured on the vendored sample paper:
    • before this change, the page answered with the fingerprint of the LF text (501dfe617f20e728) and the save path computed the fingerprint of the same paragraph with its CRLF endings (145322cc931203af) → HTTP 409 BLOCK_STALE;
    • after this change the page answers with 145322cc931203af, the same value the save path computes, the save returns HTTP 200, and the file on disk is byte-identical to the file before the save (same bytes, same CRLF endings);
    • the same flow with an LF body returns HTTP 200 and leaves the file byte-identical, with no CRLF introduced;
    • the same flow with a CRLF file and the LF text a browser sends returns HTTP 200 and leaves the file byte-identical, still CRLF;
    • the new regression test is red against 3adf295 (409) and green with this change.
  • Measured on the vendored sample paper, saving through this package's own write path:
    • a CRLF section — 678 bytes, 11 CRLF endings — came back as 678 bytes with 11 CRLF endings, the same sha256 and the same text;
    • an LF section — 667 bytes, 11 LF endings — came back byte-identical, with no CRLF introduced;
    • a mixed section — 668 bytes, 1 CRLF + 10 LF — came back byte-identical, still mixed, not unified.
  • The same three saves with the previous engine needed the Node layer to repair the file afterwards (repaired: 1 for the CRLF file and for the mixed file); with the new engine the engine's own write is already faithful and nothing has to be repaired.
  • At the engine level: reading a CRLF file with the previous code returned line1\nline2\n; the new read_text_exact returns line1\r\nline2\r\n.
  • On that Windows host, same machine and same commands before and after (A/B):
    • doctor, fonts --status, mirror-check, review and tide under cp936: exit 4 to exit 0; audit --json unchanged (exit 1 both ways);
    • a section file that is a symlink cycle: uncaught RuntimeError with no code, now a ConfigError with SECTION_PATH_INVALID / PATH_ESCAPE, and zero bytes written outside the project (the directory snapshot is identical before and after);
    • a section symlinked outside the project: unchanged refusal, unchanged wording;
    • an in-project symlink: still written through;
    • the newline-fidelity checks above (CRLF / LF / mixed): byte-identical results before and after - no regression;
    • the package's own node tests, 22 cases including the 3 that start the vendored Python engine and save into a copy of the sample paper and the 3 new paragraph-fingerprint cases: all green on the Windows host. The CRLF fingerprint save path therefore works on the real Windows host, not only on macOS.

What was not verified

  • The Mini App on Windows, through the host UI. The vendored engine and the package's own test suite were run on a real Windows host, but the package was not installed into MiniMax Code there and the page was not driven by hand. The interpreter was found on PATH and the engine started, so Windows discovery is exercised for that candidate shape; the py launcher, the versioned commands and the install-directory candidates are still only covered by unit tests.
  • Linux hosts, as before: the package ships no platform-specific binary and the Node entry uses only Node built-ins, but nothing has been run on Linux.
  • The write side of the newline fix still rests on documented Windows behaviour, not on a measurement. On POSIX the platform default text mode is the identity when writing, so the double-CR corruption cannot be produced on macOS at all; only the read side is observable there. The Windows run above measured the landing-point and console defects, not that write-side corruption.
  • The engine source tree this package vendors from still carries the old line-ending basis. This PR changes the vendored copy inside the package; the mirror in the engine repository (the tree miniapp/build.sh copies) needs the same change, otherwise the next re-vendor would undo it. That is a separate change in the engine repository and is deliberately not part of this PR.
  • The AI-draft insertion path still writes its inserted block with LF line endings (factscribe/workbench/write.py::_draft_insertion uses a hard-coded "\n"), so inserting an AI draft into a CRLF manuscript leaves LF lines in it. That path is not the fingerprint save path this review is about, and it was left untouched here.
  • The paragraph fingerprint is now strict about line endings. Because it is a fingerprint of the block's own bytes, a manuscript whose line endings were changed elsewhere (CRLF → LF) no longer matches the fingerprint the page holds, and the save is refused with 409 BLOCK_STALE until the page is reloaded. That is the intended meaning of the gate ("this DOM was rendered from this version of the file"), but it is a behaviour change for line-ending-only edits made outside the app.

npm run check warnings

None — the package reports 0 errors and 0 warnings, so there is nothing to explain.

Access and minimum client version

No new access is declared, and the minimum client version is unchanged at 3.1.2. plugin.json moves from 1.1.0 to 1.2.0.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

UncleMoc added 2 commits November 25, 2026 19:11
Two fixes: one for Windows machines, one for manuscripts that use CRLF.

1. Windows interpreter discovery

   The candidate list had no Windows shape at all -- no "py" launcher, no
   versioned command, no common install directory -- and a failed probe was
   collapsed into "not installed". A user with Python 3.9 on the machine was
   told to "install Python >=3.10", with nothing to act on.

   - new miniapp/node/python_discovery.mjs: candidates are {command, args}
     and cover py, py -3, py -3.10 ... py -3.14, py.exe, versioned commands,
     python.exe and absolute paths under %LOCALAPPDATA%, %PROGRAMFILES% and
     C:\Python3xx -- 36 candidates on Windows. The macOS/Linux list is
     unchanged, word for word.
   - the probe classifies the outcome: version high enough / too low /
     command missing / present but the version cannot be read. The message
     therefore names the version it found and the executable it came from.
   - discovery and engine start share one "command + prefix arguments" pair,
     so "py -3" is used for both, not only for probing.
   - the settings page and the engine start failure share one message:
     not installed / too old (3.9 and below cannot run this engine) /
     installed but not on PATH (point FS_PYTHON at it) / Microsoft Store
     placeholder alias that cannot report its version.

   The requirement is unchanged: the engine needs Python >= 3.10.

2. Browser-layer CRLF preservation

   The engine reads sections with Python's universal-newline mode (CRLF
   becomes LF before the text ever reaches the page) and writes the file
   back byte for byte, so every save rewrote the whole file with LF
   endings -- a CRLF manuscript lost all its CR bytes on the first edit.

   - new miniapp/node/eol.mjs: split with the endings kept apart, recognise
     crlf / lf / mixed, put the original endings back.
   - the Node shell reads the real endings from disk before the save, hands
     the engine an LF-only body and restores the endings afterwards: lines
     the save did not touch keep their exact endings (a mixed file stays
     mixed), the edited lines take the file's dominant ending, and the text
     is never altered -- only the endings move. If the file changed
     underneath while the save ran, the endings are left alone.

The vendored Python engine is untouched by both changes.

Verified:
- upstream checker: plugins/unclemoc/factscribe OK (0 errors, 0 warnings);
  npm run check exits 0 (92/92 checker self-tests).
- package tests: node --test tests/*.test.mjs -- 19 cases, all green
  (16 unit cases for the line-ending module, plus 3 end-to-end cases that
  start the vendored Python engine and save into a copy of the sample
  paper).
- measured on the vendored sample paper: a 678-byte section with 11 CRLF
  endings came back with all 11 endings and the same text; without the fix
  the engine's own save rewrote it as 667 bytes with 0 CRLF.

Not verified:
- Windows end to end. There is no Windows machine here. The 36 Windows
  candidates are generated from the platform string and covered by unit
  tests, but no run on a real Windows host has been done.
- Linux hosts, as before.
…ackage

The vendored copy of the Python engine in this package predates the
newline-fidelity work. It read user files in universal-newline mode, so a
CRLF file was already LF by the time the text reached the page, and it
wrote several user-owned files in platform default text mode, where a CRLF
string is written as \r\r\n on Windows. The Node shell restored the
endings after each save, but the engine itself still lost them, and the
Node layer can only put a file back when its line contents still match.

Re-vendor the engine from the FactScribe source tree, which now carries
the newline-fidelity work:

- new factscribe/textio.py: read_text_exact / write_text_exact /
  append_text_exact keep the file's own line endings, and to_lf gives the
  analysis layer an explicit normalisation point;
- the read side uses read_text_exact, the write side write_text_exact;
- machine-generated artefacts (JSON reports, audit matrices, manifests)
  keep using the platform default, so their format stays predictable.

The vendored tree is produced by miniapp/build.sh and is byte-identical to
the source tree apart from the excluded web/ directory.

Measured on the vendored sample paper, saving through this package: a
678-byte section with 11 CRLF endings came back as 678 bytes with 11 CRLF
endings and the same sha256; the LF file (667 bytes, 11 LF) and the mixed
file (668 bytes, 1 CRLF + 10 LF) came back byte-identical. With the
previous engine the Node layer had to repair the file after every CRLF and
mixed save; with this engine the engine's own write is already faithful.

Not verified: Windows end to end, and Linux.

Copy link
Copy Markdown
Collaborator

A blocking save issue was reproduced at 908bdf92: after opening a document whose body contains multiple lines with CRLF line endings, saving it with the paragraph fingerprint returned by the page fails with HTTP 409. The display and save paths handle line endings differently, so the fingerprint returned by the page fails validation on save.

Please make line-ending handling and fingerprint calculation consistent across both paths while preserving the document's original CRLF line endings on save. Add a regression test covering the full flow: retrieve the paragraph fingerprint from the page response, then use it to successfully save a multiline CRLF body.

This issue blocks merging. We'll review the updated commit once the fix is ready.

moc and others added 2 commits November 26, 2026 00:36
…ackage

Two Windows defects that the vendored engine still had, found on a real
Windows host (winbox 10.0.1.9, ACP=936) and fixed in the engine source
tree before re-vendoring it.

D1 - a write-side landing point that cannot be resolved must be refused,
not crash.

  The engine resolved write targets with pathlib.Path.resolve(). On a
  symlink cycle that raises RuntimeError on Python 3.10-3.12 (and does
  not raise at all on 3.13+), so a section file that was a symlink loop
  escaped as an uncaught exception - "internal error", exit 4 - instead
  of a refusal with a judgement code. A section symlinked outside the
  project escaped the same way from the closure builder.

  New factscribe/landing.py owns landing resolution: it resolves with
  os.path.realpath(strict=True) (same answer on every Python version),
  treats "cannot be resolved" as a semantic condition rather than an
  errno whitelist (Windows raises winerror=1921 / errno=EINVAL for a
  cycle, not ELOOP - errno.ELOOP is 10062 there), and the three write
  gates - _safe_section_file, _root_tex_file, write_section_data - now
  refuse with their own existing codes (SECTION_PATH_INVALID /
  PATH_ESCAPE) instead of crashing. The "outside the project root"
  wording is unchanged, and an in-project symlink is still written
  through.

D2 - a Chinese Windows console must not break the tool.

  The human-readable output contains U+2713 / U+2717 / U+2194, which
  cp936 cannot encode. print() raised UnicodeEncodeError, and the
  command layer turned that into exit 4. New factscribe/console.py
  installs a custom encoding error handler on stdout/stderr at the CLI
  entry: characters that cannot be encoded become equivalent ASCII
  (checkmark -> v, xmark -> x, arrow -> <->), the command runs to
  completion and keeps its own exit code, the stream keeps its own
  encoding, and --json payloads are unchanged.

The vendored tree is still generated by miniapp/build.sh and is
byte-identical to the source tree apart from the excluded web/ directory.

Measured on the real Windows host, same machine and same commands before
and after (A/B):

  * doctor / fonts --status / mirror-check / review / tide under cp936:
    exit 4 -> exit 0; audit --json unchanged (exit 1 both ways);
  * a section file that is a symlink cycle: uncaught RuntimeError with
    no code -> ConfigError SECTION_PATH_INVALID / PATH_ESCAPE, and
    zero bytes written outside the project;
  * a section symlinked outside the project: unchanged refusal and
    unchanged wording;
  * an in-project symlink: still written through;
  * the F4 newline fidelity checks (CRLF / LF / mixed): byte-identical
    results before and after - no regression;
  * the package's own node tests, 19 cases including 3 that start the
    vendored Python engine: all green on the Windows host.

Not verified: the Mini App installed and driven through the host UI on
Windows; Linux.
The page and the save path read the same manuscript differently, and the
paragraph fingerprint is a sha256 over that text - so a manuscript with CRLF
line endings could not be saved with the fingerprint the page had just
given.

The page side went through the audit closure, which reads in universal
newline mode: a CRLF file was already LF by the time the paragraph
reached the browser. The save side reads the file byte-exact, so the raw
it fingerprints still had its CR bytes in it. The two sides therefore
disagreed by exactly the CR bytes, and saving such a paragraph was
refused with HTTP 409 BLOCK_STALE. A paragraph whose text is a single
line hid it - there are no CR bytes inside it, so both sides happened to
agree.

Reproduced at 908bdf9 and still present at 3adf295: open a document
whose body has several CRLF lines, take the paragraph fingerprint from
the page response, save with it - HTTP 409, BLOCK_STALE.

Both sides now use the file's own bytes:

- workbench/projects.py::_section_files reads each section file with
  read_text_exact instead of taking the closure's universal-newline text,
  so the raw the page is rendered from is the raw the save path
  fingerprints. The cover abstract follows the same rule in both of its
  layouts (section file and root file), which used to disagree as well.

- The fingerprint itself is unchanged (sha256 over the block raw, first
  16 hex digits); only the text it is taken over is now the same on both
  sides.

Saving still preserves the manuscript's own line endings, byte for byte:

- New factscribe/textio.py::restore_newlines puts the block's original
  endings back on the text that is about to be written. A contenteditable
  always hands back LF, so without this a CRLF file would lose its CR
  bytes on the first save. The endings are restored per line, so a file
  with mixed endings stays mixed, and endings the block did not have are
  taken from the file.

- The structural work (protection-surface scan, anchor re-insertion,
  surface comparison) runs on the LF-normalised copy on both sides, so a
  CRLF manuscript takes exactly the same decisions as an LF one.

- New regression test tests/save-fingerprint.test.mjs covers the whole
  flow the review names: take the paragraph fingerprint from the page
  response, save a multi-line CRLF body with it, and assert that the
  save succeeds and that the file on disk is byte-identical to the file
  before the save. A second case does the same for an LF body (it must
  not come back as CRLF), and a third one sends the LF text a browser
  actually sends for a CRLF file (it must come back as CRLF).

- tests/save-eol.test.mjs now derives the package root with
  fileURLToPath, so the package's own test suite also runs on Windows
  (a URL pathname is /C:/... there).

Measured:

- macOS 26.6.2, Node 26.7, Python 3.14: the reproduction above returns
  HTTP 200 and the file is unchanged byte for byte. The new test is red
  against 3adf295 (409 BLOCK_STALE) and green with this change.
- Package tests: node --test tests/*.test.mjs - 22 cases, all green (the
  three new ones start the vendored Python engine and save into a copy
  of the sample paper).
- Windows NT 10.0.26200.9974 (winbox 10.0.1.9, ACP=936), portable
  Python 3.12.10, Node 24.22.2: the same 22 cases green, including the
  three new ones - the CRLF fingerprint save path works on the real
  host. The newline fidelity checks (CRLF / LF / mixed) are byte
  identical to the disk, a symlink cycle is still refused with
  SECTION_PATH_INVALID / PATH_ESCAPE and writes nothing outside the
  project, and the human-readable commands still exit 0 under cp936.
- Upstream checker: plugins/unclemoc/factscribe: OK - 0 errors, 0
  warnings. npm run check exits 0 (92/92).
- The engine's own Python suite against the vendored copy inside this
  package: 2399 cases and 397 subtests, all green.

Not changed: no judgement code, no exit code, no wording; the golden
baseline is untouched.
@UncleMoc

Copy link
Copy Markdown
Contributor Author

Fixed in 9912594 — the paragraph fingerprint and the save path now use one line-ending basis, and CRLF bodies still save as CRLF.

The two sides disagreed by exactly the CR bytes: the page side went through the audit closure, which reads in universal-newline mode (a CRLF file was already LF by the time the paragraph reached the browser), while the save side fingerprinted the file byte-exact. Both now read the file's own bytes.

Regression test added in this PR: plugins/unclemoc/factscribe/tests/save-fingerprint.test.mjs takes the paragraph fingerprint from the page response and saves a multiline CRLF body with it — the flow that returned HTTP 409 BLOCK_STALE before.

Happy to rebase or split the commits if that helps review.

@MyPrototypeWhat
MyPrototypeWhat merged commit be73247 into MiniMax-AI:main Nov 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants